package com.wl.upload.web;

import com.wl.upload.UploadConfiguration;
import com.wl.upload.bean.UploadProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.xml.transform.Result;
import java.io.IOException;
import java.util.UUID;

@RestController
@RequestMapping("upload")
public class UploadDo {
    @Autowired
    UploadProperties properties;
    @GetMapping("config")
    UploadConfiguration properties() {
        return properties;
    }

    @PostMapping("upload")
    public Result upload(@RequestParam("file") MultipartFile file,
                         String type) throws IOException {
        UploadProperties.FileConfig fileConfig = properties.getConfig().get(type);
        String filename = file.getOriginalFilename();
        String prefix = UUID.randomUUID().toString().replace("-","");
        String suffix = filename.substring(filename.lastIndexOf("."));

    }
}
